package com.cis.teacher.controller;

import com.cis.teacher.domain.EduTeacher;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/index")
public class IndexController {


    private String prefix = "/index";

    /**
     * 跳转到登录页面
     *
     */
    @GetMapping("/login")
    public String login(){
        return prefix + "/login";
    }

    @PostMapping("/loginuser")
    @ResponseBody
    public String getLoginUser(HttpServletRequest request, EduTeacher eduTeacher){
        HttpSession session = request.getSession();
        session.setAttribute("user",eduTeacher);
        return "/";
    }
}
